package com.jk.testsql.aop;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

@Slf4j
public class RoutingDataSource extends AbstractRoutingDataSource {
    /**
     * 检索当前目标数据源
     * @return
     */
    @Override
    protected Object determineCurrentLookupKey() {
        log.info(">>>线程：{},数据源：{}<<<", Thread.currentThread().getName(),DataSourceContextHolder.getDbContextLocal());
        return DataSourceContextHolder.getDbContextLocal();
    }
}

